#ifndef GAMEENGINE_CORE_MEMORY_ALLOCATOR_DEFAULT_HPP
#define GAMEENGINE_CORE_MEMORY_ALLOCATOR_DEFAULT_HPP


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif


//========================================================



//! Allocate data
/*!
 *  The AllocatorDefault class allocates data using the standard C++ new operator
 *
 @param nb_elements The number of elements to be allocated
 */
template <class T>
T* AllocatorDefault<T>::allocate(unsigned int nb_elements) {
	if ( nb_elements == 0 ) return nil;
	if ( nb_elements == 1 ) return new T;
	return new T[nb_elements];
}

//! Allocate one single data using the copy constructor
/*!
 *  The AllocatorDefault class allocates data using the standard C++ new operator
 *
 @param rhs The data to copy
 */
template <class T>
T* AllocatorDefault<T>::copy(const T& rhs) {
	return new T(rhs);
}

//! Desallocate data
/*!
 *  The AllocatorDefault class desallocates data using the standard C++ delete operator
 */
template <class T>
void AllocatorDefault<T>::desallocate(const T* item, unsigned int nb_elements) {
	if ( nb_elements <= 1 ) delete item;
	else delete [] item;
}

//========================================================

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
